<%@Page Language="VB" %>
<%@Import Namespace="System.XML" %>
<html><head>
<title>Searching an XML document using the DOM</title>
</head>
<body bgcolor="#ffffff">
<span class="heading">Searching an XML document using the DOM</span><hr />
<!--------------------------------------------------------------------------->

<div id="outDocURL" runat="server"></div>
<div id="outError" runat="server">&nbsp;</div>
<div id="outResults" runat="server"></div>
<script language="vb" runat="server">
Sub Page_Load()

   Dim strCurrentPath As String = Request.PhysicalPath
   Dim strXMLPath As String = Left(strCurrentPath, InStrRev(strCurrentPath, "\")) & "booklist.xml"
   Dim objXMLDoc As New XmlDocument()
   Try
      objXMLDoc.Load(strXMLPath)
      outDocURL.innerHTML = "Loaded file: <b>" & strXMLPath & "</b>"
   Catch objError As Exception
      outError.innerHTML = "<b>* Error while accessing document</b>.<br />" _
          & objError.Message & "<br />" & objError.Source
      Exit Sub  

   End Try

   Dim strResults As String = "<b>List of authors</b>:<br />"

   Dim colElements As XmlNodeList
   colElements = objXMLDoc.GetElementsByTagname("AuthorName")
   Dim objNode As XmlNode
   For Each objNode In colElements
      strResults += objNode.FirstChild().Value & "<br />"
   Next

   outResults.innerHTML = strResults   'display the result

End Sub
</script>
</body>
</html>
